import os
from werkzeug import secure_filename


def write_mr_denpendency_analyze(file, project_id, git_commit, mr_id):
  filename = "%s_%s_%s.md" %(project_id, git_commit, mr_id)
  file.save(os.path.join('./denpendency_analyze_files', filename))
  return filename


def read_mr_denpendency_analyze(project_id, git_commit, mr_id):
  filename = "%s_%s_%s.md" %(project_id, git_commit, mr_id)
  filepath = "./denpendency_analyze_files/%s" %(filename)
  f = open(filepath,"r") 
  file_content = f.read()
  f.close()
  return file_content


def del_mr_denpendency_analyze(project_id, git_commit, mr_id):
  filename = "%s_%s_%s.md" %(project_id, git_commit, mr_id)
  filepath = "./denpendency_analyze_files/%s" %(filename)
  os.remove(filepath)

# def write_mr_denpendency_analyze(file):
#   filename = secure_filename(file.filename)
#   file.save(os.path.join('./denpendency_analyze_files', filename))

